import * as THREE from 'three'
import scene from "@/three/Scene";
import renderer from "@/three/renderer";
import camera from "@/three/Camera";
import { Water } from 'three/examples/jsm/objects/Water';
// 导入water
export default class WaterPlane{
    constructor(scene) {
        this.scene = scene
        const waterGeometry = new THREE.PlaneGeometry(10000, 10000);

        this.water = new Water(
            waterGeometry,
            {
                textureWidth: 512,
                textureHeight: 512,
                waterNormals: new THREE.TextureLoader().load('texture/waternormals.jpg', function (texture) {
                    texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
                }),
                sunDirection: new THREE.Vector3(),
                sunColor: 0xffffff,
                waterColor: 0x001e0f,
                distortionScale: 3.7,
                fog: this.scene.fog !== undefined,
            }
        );

        this.water.rotation.x = - Math.PI / 2;
        this.water.position.y = -2
        // console.log(this.water)
        scene.add(this.water);
    }
}
